//
//  YATaskGameGetRecommendList.m
//  YoucApi
//
//  Created by Liam on 11/15/12.
//
//

#import "YATaskGameGetRecommendList.h"
#import "YAObjRecommend.h"

@implementation YATaskGameGetRecommendList

TASK_AUTO_REGISTER(TaskGameGetRecommendList);

- (NSString *)_getUriParamA
{
	return @"get_recommend";
}

- (void)_dealWithJSONResponse:(id)responseObject withError:(NSError *)error
{
	YARespGameList *respGameList = [[[YARespGameList alloc] initWithError:error context:self.context] autorelease];
	
	NSMutableArray *list = nil;
	
	if ([error code] == YoucApiErrorSuccess)
	{
		list = [NSMutableArray array];
        
		NSArray *jsonList = (NSArray *)responseObject;
		for (NSDictionary *item in jsonList)
		{
			YAObjRecommend *recommend = [[[YAObjRecommend alloc] init] autorelease];
			recommend.serverName = SAFE_STRING([item objectForKey:KEY_SERVERNAME]);
			recommend.serverTime = [SAFE_STRING([item objectForKey:KEY_SERVERTIME]) doubleValue];
			recommend.platformName = SAFE_STRING([item objectForKey:KEY_PLATFORMNAME]);
			recommend.platformUrl = SAFE_STRING([item objectForKey:KEY_PLATFORMURL]);
            recommend.gameName = SAFE_STRING([item objectForKey:KEY_GAMENAME]);
            recommend.gameImage = SAFE_STRING([item objectForKey:KEY_IMAGE]);
			recommend.gameUrl = SAFE_STRING([item objectForKey:KEY_GAMEURL]);
			[list addObject:recommend];
		}
	}
    
	respGameList.list = list;
	
	if ([self.delegate respondsToSelector:@selector(getGameListResponse:respGameList:)])
	{
		[self.delegate getGameListResponse:self respGameList:respGameList];
	}
}

@end
